package com.doyens.gmall.item.controller;

import com.doyens.gmall.common.result.Result;
import com.doyens.gmall.item.service.ItemService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("api/item")
@Slf4j
public class ItemApiController {
    @Autowired
    private ItemService itemService;

    @GetMapping("{skuId}")
    //通过skuId获取详情页面所有信息
    public Result getItem(@PathVariable("skuId") Long skuId){
        //skuInfo,sku信息
        //skuImage,sku图片
        //sale attr,销售属性.....
       Map<String,Object> map =  itemService.getItem(skuId);
       log.info("getItem 的结果"+map);
       return Result.ok(map);
    }
}
